package com.atguigu.lease.web.admin.custom.comverter;

import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.model.enums.LeaseStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
/**
 * description:
 *
 * @author:MING
 * @time:2025-02-25-19:17-16
 * @version:
 */
public class StringToLeaseStatusConverter implements Converter<String, LeaseStatus> {
    @Override
    public LeaseStatus convert(String source) {
        LeaseStatus[] value = LeaseStatus.values();
        for (LeaseStatus itemType : LeaseStatus.values()) {

            if (itemType.getCode().equals(Integer.valueOf(source))) {
                return itemType;
            }
        }
        throw new IllegalArgumentException("code非法"+source);
    }

}